package com.situ.firmadmin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.situ.firmadmin.mapper.OperLogMapper;
import com.situ.firmadmin.pojo.OperLog;
import com.situ.firmadmin.pojo.query.OperLogQuery;
import com.situ.firmadmin.service.IOperLogService;
import com.situ.firmadmin.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperLogServiceImpl implements IOperLogService {

    @Autowired
    private OperLogMapper operLogMapper;

    @Override
    public void add(OperLog operLog) {
        operLogMapper.add(operLog);
    }

    @Override
    public PageResult normalList(OperLogQuery operLogQuery) {
        PageHelper.startPage(operLogQuery.getPage(), operLogQuery.getLimit());
        List<OperLog> normalList=operLogMapper.normalList(operLogQuery);
        PageInfo pageInfo=new PageInfo(normalList);
        int totalCount=(int)pageInfo.getTotal();
        return new PageResult(0,"",totalCount,normalList);
    }

    @Override
    public OperLog selectById(Integer id) {
        return operLogMapper.selectById(id);
    }

    @Override
    public PageResult abnormalList(OperLogQuery operLogQuery) {
        PageHelper.startPage(operLogQuery.getPage(), operLogQuery.getLimit());
        List<OperLog> abnormalList=operLogMapper.abnormalList(operLogQuery);
        PageInfo pageInfo=new PageInfo(abnormalList);
        int totalCount=(int)pageInfo.getTotal();
        return new PageResult(0,"",totalCount,abnormalList);
    }

    @Override
    public void deleteAll(Integer[] ids) {
        operLogMapper.deleteAll(ids);
    }

    @Override
    public void deleteById(Integer id) {
        operLogMapper.deleteById(id);
    }

    @Override
    public void deleteAllNormal() {
        operLogMapper.deleteAllNormal();
    }
    
    @Override
    public void deleteAllAbnormal() {
        operLogMapper.deleteAllAbnormal();
    }
}
